<template>
    <view class="content">
        <view style="height: 20rpx;"></view>
        <view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item.id)">
            <view class="times">
                <text class="tt">{{item.create_time}}</text>
            </view>
            <view class="otx">
                <image v-if="item.title_pic_url" :src="item.title_pic_url" class="pic"></image>
                <view class="pox">
                    <view class="t1 u-line-1">{{item.title}}</view>
                    <view class="t2 u-line-1" v-if="item.ftitle">{{item.ftitle}}</view>
                </view>
            </view>
        </view>
        
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
            };
        },
        onLoad(option) {
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            goDetail(id) {
                this.$gTo(`/pages/notice/detail?id=${id}`)
            },
            
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('contentsList', {
                    userToken: this.$getSync('userToken'),
                    page: this.page,
                    limit: 10,
                    column_id: 1,//1-平台公告 7-新闻资讯
                }).then(ret => {
            		if (ret.status == 0) {
                        if (ret.data.length > 0) {
                        	this.list = this.list.concat(ret.data);
                        	this.page++;
                        	this.status = 'loadmore'
                        } else {
                        	this.status = 'nomore'
                        }
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style scoped lang="scss">
    .content {
        min-height: 100vh;
        background: #f5f5f5;
    }

    .times {
        display: flex;
        justify-content: center;
        margin-bottom: 20rpx;

        .tt {
            border-radius: 100px;
            padding: 0 20rpx;
            color: #fff;
            background: #dfdfdf;
            font-size: 22rpx;
            line-height: 44rpx;
        }
    }

    .otx {
        width: 710rpx;
        // height: 426rpx;
        padding-bottom: 30rpx;
        border-radius: 18rpx;
        box-shadow: 0 0 18rpx 0 rgba(0, 0, 0, 0.05);
        background-color: #fff;
        margin: 0 auto 48rpx;
        overflow: hidden;

        .pic {
            display: block;
            width: 710rpx;
            height: 280rpx;
        }

        .pox {
            padding: 30rpx 40rpx 0;

            .t1 {
                font-size: 30rpx;
                color: #000000;
            }

            .t2 {
                margin-top: 20rpx;
                font-size: 24rpx;
                color: #666666;
            }
        }
    }
</style>